package com.chuangshi.core.vote.position.controller.mobile;

import com.chuangshi.core.kit.Controller;
import com.chuangshi.core.vote.position.controller.mobile.request.PositionMobileV1ListRequest;
import com.chuangshi.core.vote.position.controller.mobile.response.PositionMobileV1ListResponse;
import com.chuangshi.core.vote.position.entity.Position;
import com.chuangshi.core.vote.position.service.PositionService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 岗位信息移动端控制器
 *
 * @author ggliming
 * @date 2019-02-21
 */
@Api(tags = "岗位信息移动端控制器")
@RestController
public class PositionMobileController extends Controller {

    @Autowired
    private PositionService positionService;

    @ApiOperationSort(value = 10)
    @ApiOperation(value = "获取岗位信息列表", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PositionMobileV1ListRequest")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "返回参数", response = PositionMobileV1ListResponse.class)
    })
    @RequestMapping(value = "/vote/position/mobile/v1/list", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> v1List(@ApiIgnore @RequestBody PositionMobileV1ListRequest body) {
        validateRequest(body);

        List<Position> positionList = positionService.listAll(body.getAppId());
        validateResponse(PositionMobileV1ListResponse.class);

        return renderJson(positionList);
    }

//    @ApiOperationSort(value = 20)
//    @ApiOperation(value = "获取单条岗位信息", httpMethod = "POST")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PositionMobileV1FindRequest")
//    })
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "返回参数", response = PositionMobileV1FindResponse.class)
//    })
//    @RequestMapping(value = "/vote/position/mobile/v1/find", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> v1Find(@ApiIgnore @RequestBody PositionMobileV1FindRequest body) {
//        validateRequest(body);
//
//        validateResponse(PositionMobileV1FindResponse.class);
//
//        return renderJson(new PositionMobileV1FindResponse());
//    }
//
//    @ApiOperationSort(value = 30)
//    @ApiOperation(value = "新增岗位信息", httpMethod = "POST")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PositionMobileV1SaveRequest")
//    })
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "新增成功")
//    })
//    @RequestMapping(value = "/vote/position/mobile/v1/save", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> v1Save(@ApiIgnore @RequestBody PositionMobileV1SaveRequest body) {
//        validateRequest(body);
//
//        Boolean result = false;
//
//        return renderJson(result, result ? "新增成功" : "新增不成功");
//    }
//
//    @ApiOperationSort(value = 40)
//    @ApiOperation(value = "修改岗位信息", httpMethod = "POST")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PositionMobileV1UpdateRequest")
//    })
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "修改成功")
//    })
//    @RequestMapping(value = "/vote/position/mobile/v1/update", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> v1Update(@ApiIgnore @RequestBody PositionMobileV1UpdateRequest body) {
//        validateRequest(body);
//
//        Boolean result = false;
//
//        return renderJson(result, result ? "修改成功" : "修改不成功");
//    }
//
//    @ApiOperationSort(value = 50)
//    @ApiOperation(value = "删除岗位信息", httpMethod = "POST")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PositionMobileV1DeleteRequest")
//    })
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "删除成功")
//    })
//    @RequestMapping(value = "/vote/position/mobile/v1/delete", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> v1Delete(@ApiIgnore @RequestBody PositionMobileV1DeleteRequest body) {
//        validateRequest(body);
//
//        Boolean result = false;
//
//        return renderJson(result, result ? "删除成功" : "删除不成功");
//    }

}